package cn.net.yato.picture.mapper;

import cn.net.yato.picture.entity.UserHeadImg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName UserHeadImgMapper
 * @Description TODO
 * @Author yato
 * @Date 2020/2/17 14:41
 * @Version 1.0
 */
@Component
public interface UserHeadImgMapper extends BaseMapper<UserHeadImg> {

    /**
     * 查询所有头像文件信息
     * @return
     */
    @Select("SELECT  userheadimg.id,userheadimg.file_id,userheadimg.user_id," +
            "userheadimg.file_name,userheadimg.file_size,userheadimg.file_path," +
            "userheadimg.file_loc_path,userheadimg.file_update_time," +
            "userheadimg.file_state  FROM  userheadimg")
    @Results(id = "userHeadImgResult", value = {
            @Result(property = "id", column = "id"),
    })
    List<UserHeadImg> getAllUserHeadImgs();

    /**
     * 根据头像文件ID得到图片文件信息
     * @param fileId
     * @return
     */
    @Select("SELECT  userheadimg.id,userheadimg.file_id,userheadimg.user_id," +
            "userheadimg.file_name,userheadimg.file_size,userheadimg.file_path," +
            "userheadimg.file_loc_path,userheadimg.file_update_time," +
            "userheadimg.file_state  FROM  userheadimg  WHERE  userheadimg.file_id = #{fileId}")
    @ResultMap(value = "userHeadImgResult")
    UserHeadImg getUserHeadImgByFileId(@Param(value = "fileId") String fileId);

    /**
     * 根据头像用户ID得到图片文件信息--->历史头像
     * @param userId
     * @return
     */
    @Select("SELECT  userheadimg.id,userheadimg.file_id,userheadimg.user_id," +
            "userheadimg.file_name,userheadimg.file_size,userheadimg.file_path," +
            "userheadimg.file_loc_path,userheadimg.file_update_time," +
            "userheadimg.file_state  FROM  userheadimg  WHERE  userheadimg.user_id = #{userId}")
    @ResultMap(value = "userHeadImgResult")
    List<UserHeadImg> getUserHeadImgsByUserId(@Param(value = "userId") String userId);
}
